package com.job.ZhangMeng.Homework0707;

import java.util.Arrays;

/**
 * 2022.07.07  MyHelper--JavaBean练习
 * 张孟
 */

class MyHelper
{
    private String name;
    private int age ;
    private String dep;

    public void showInfo()
    {
        System.out.println("姓名："+this.name+"\t年龄："+this.age+"\t专业："+this.dep);
    }
    public void setInfo(String name,int age,String dep)
    {
        this.name=name;
        this.age=age;
        this.dep=dep;
    }
    public int helper(int[] x)
    {
        Arrays.sort(x);
        int l=x.length;
        int sum=0,mid=l/2;
        for(int i=0;i<l;i++)
            sum+=x[i];
        int aver=sum/l;
        return x[mid]<aver ? aver : x[mid];
    }

    public MyHelper(){}
    public MyHelper(String n,int a,String d)
    {
        this.name=n;
        this.age=a;
        this.dep=d;
    }
}

public class Homework0707_B{

    public static void main(String[] args) {
        MyHelper mh=new MyHelper("张孟",19,"计算机科学与技术");
        int[] arr={9,14,8,1,2,7,4};  //排序后为{1,2,4,7,8,9,14}  中间值7 > 平均值6(int自动取整),返回中间值7
        mh.showInfo();
        int result=mh.helper(arr);
        System.out.println(result);
        mh.setInfo("RickAstley", 56, "你 被 骗 了");
        mh.showInfo();
    }

}
